package com.xg.model.dto;

import com.xg.validator.annotation.ConditionalRequired;
import com.xg.validator.annotation.MaxLength;
import com.xg.validator.annotation.Required;
import com.xg.model.enums.CompareOperator;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.Pattern;
import lombok.Data;

@Data
public class UserRequest {

    @Required(message = "姓名不能为空")
    @MaxLength(20)
    private String name;

    @Required(message = "手机号不能为空")
    @MaxLength(11)
    @Pattern(regexp="^1[3-9]\\d{9}$", message = "手机号格式不正确")
    private String phone;

    private Integer age;

    @ConditionalRequired(conditionField = "age", conditionValues = {"18"}, operator = CompareOperator.GTE)
    private String idCard;  // 如果年龄是>18岁，身份证号必须填写

    @ConditionalRequired(conditionField = "name", conditionValues = {"张三","李四"})
    private String address;  // 如果名字是张三，住址必须填写

    @Email(message = "邮箱格式不正确")
    @ConditionalRequired(conditionField = "name", conditionValues = {"张三","李四"})
    private String email;
}
